/***************************************************************************
 *   Copyright (C) 2008 by Burdakov Daniel   *
 *   kreved@kreved.org   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


#ifndef NCLIENT_H
#define NCLIENT_H

#include <QtGui>
#include <QHttp>

class QHttpResponseHeader;

class nclient:public QWidget
{
      Q_OBJECT

public:
      nclient();
      ~nclient();

private slots:
    void openSettings();
    void saveSettings();
    void showStatus();
    void update();
    void disableInet();
    void readResponseHeader(const QHttpResponseHeader &);
    void httpRequestFinished(int, bool);
    void trayIconActivated(QSystemTrayIcon::ActivationReason);
    void quit();

private:
    void createActions();
    void createTrayIcon();
    void setIcon(QString);
    void setToolTip(QString);
    void err(QString);
    void parseResponse(QString);
    void saveConfig();
    void loadConfig();
    QString calc_key();
    
    QAction *showStatusAction;
    QAction *updateAction;
    QAction *settingsAction;
    QAction *quitAction;
    
    QSettings *config;
    QLabel *usernameLabel;
    QLineEdit *usernameEdit;
    QLabel *passwordLabel;
    QLineEdit *passwordEdit;
    QCheckBox *rememberCheckBox;
    QPushButton *btnOK;
    QPushButton *btnCancel;
    QSystemTrayIcon *trayIcon;
    QMenu *trayIconMenu;
    QHttp *http;
    
    QString skey;
    QString host;
    QString prefix;
    int reqID;
    bool authFailed;
    bool shuttingDown;
};

#endif
